package com.leo.ktvplayer.ui.setting;

import android.app.AlertDialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.leo.ktvplayer.R;
import com.leo.ktvplayer.util.ToastUtil;

/**
 *
 */
public class ManagerDialog extends AlertDialog implements View.OnClickListener {
    public OnManagerDialogClickedListener listener = null;
    private EditText inputText;
    public ManagerDialog(Context context) {
        super(context);
        init();
    }

    public ManagerDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        init();
    }

    public ManagerDialog(Context context, int themeResId) {
        super(context, themeResId);
        init();
    }

    public void setOnManagerDialogClickedListener(OnManagerDialogClickedListener listener) {
        this.listener = listener;
    }

    private void init(){
        View view = getLayoutInflater().inflate(R.layout.dialog_managersetting,null);
        Button positive = (Button) view.findViewById(R.id.btn_managerdialog_positive);
        Button cancel = (Button)view.findViewById(R.id.btn_managerdialog_cancel);
        inputText = (EditText)view.findViewById(R.id.ed_managerdialog_inputtext);
        positive.setOnClickListener(this);
        cancel.setOnClickListener(this);
        setView(view);
        setCancelable(false);

    }


    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn_managerdialog_positive) {
            if (listener != null)
                 listener.Clicked(OnManagerDialogClickedListener.ACTION_POSITIVE,inputText.getText().toString());
        } else if (v.getId() == R.id.btn_managerdialog_cancel) {
            if (listener != null)
                listener.Clicked(OnManagerDialogClickedListener.ACTION_CANCEL,inputText.getText().toString());
            cancel();
        }
    }


    public interface OnManagerDialogClickedListener{
        void Clicked(int action , String edText);

        int ACTION_POSITIVE = 0;
        int ACTION_CANCEL = 1;
    }

}
